//
//  HHSwitchSettingCell.m
//  BXlive
//
//  Created by bxlive on 2018/5/2.
//  Copyright © 2018年 cat. All rights reserved.
//

#import "HHSwitchSettingCell.h"
#import <SLDeveloperTools/SLDeveloperTools.h>
#import <Masonry/Masonry.h>

@implementation HHSwitchSettingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.nextImageView.hidden = YES;
        
        _functionSwitch = [[UIButton alloc]init];
//        _functionSwitch.onTintColor = sl_normalColors;
        [_functionSwitch setBackgroundImage:CImage(@"setting_switch_off") forState:BtnNormal];
         [_functionSwitch setBackgroundImage:CImage(@"setting_switch_on") forState:BtnSelected];
        [_functionSwitch addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchDown];
        [self.contentView addSubview:_functionSwitch];
        [_functionSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-__ScaleWidth(12));
            make.centerY.mas_equalTo(0);
            make.width.mas_equalTo((49));
            make.height.mas_equalTo(22);
        }];
        
    }
    return self;
}

- (void)switchAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (_switchFunction) {
        _switchFunction(sender.selected);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
